package nginx

import (
	"fmt"
	"github.com/gogf/gf/errors/gerror"
	"gitlab.local/golibrary/utils"
	"strconv"
	"strings"
)

func (Self *service) GetHttpPort() (int, error) {
	s := fmt.Sprintf(". /etc/profile > /dev/null;. %s && get_http_port 2>&1", scriptFile)
	stdOut, err := utils.ShellExec(s)
	if err != nil {
		return 0, gerror.New("shell failed")
	}
	return strconv.Atoi(strings.TrimSpace(stdOut))
}

func (Self *service) GetHttpsPort() (int, error) {
	s := fmt.Sprintf(". /etc/profile > /dev/null;. %s && get_https_port 2>&1", scriptFile)
	stdOut, err := utils.ShellExec(s)
	if err != nil {
		return 0, gerror.New("shell failed")
	}
	return strconv.Atoi(strings.TrimSpace(stdOut))
}
